﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Threading;
using upload.Class;
using upload.Forms;

namespace upload
{

    public partial class Form2 : Form
    {
        public Form2()
        {
            //SetBrowser s1 = new SetBrowser();
            //s1.SetWebBrowserFeatures(11);
            
            //webBrowser1 Navigate("http://ie.icoa.cn/");
            InitializeComponent();
            string url = "https://document-manage-1317383760.cos.ap-shanghai.myqcloud.com//医院文件/黄昱明-广东医科大学15625874605.pdf";
            //webview.Dock = DockStyle.Fill;
            


        }

        private void button4_Click(object sender, EventArgs e)
        {
            //HtmlWindow h1 = new HtmlWindow("https://document-manage-1317383760.cos.ap-shanghai.myqcloud.com/%E5%8C%BB%E9%99%A2%E6%96%87%E4%BB%B6/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt");
            string url = "https://document-manage-1317383760.cos.ap-shanghai.myqcloud.com//医院文件/黄昱明-广东医科大学15625874605.pdf";
            //ChromiumWebBrowser webview = new ChromiumWebBrowser(url);
            Formweb f1 = new Formweb(url);
            f1.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            URL u1 = new URL();
            //u1.GetUrl();
        }

        public class ButtonEx : Button
        {
            public new event EventHandler DoubleClick;
            DateTime clickTime;
            bool isClicked = false;
            protected override void OnClick(EventArgs e)
            {
                base.OnClick(e);
                if (isClicked)
                {
                    TimeSpan span = DateTime.Now - clickTime;
                    if (span.Milliseconds < SystemInformation.DoubleClickTime-200)
                    {
                        DoubleClick(this, e);
                        isClicked = false;
                    }
                    else
                    {
                        isClicked = true;
                        clickTime = DateTime.Now;
                    }
                }
                else
                {
                    isClicked = true;
                    clickTime = DateTime.Now;
                }
            }
        }

        void btn_MouseDown(object sender, MouseEventArgs e ,string office,Button btn)
        {
            if (e. Button == MouseButtons.Left && e.Clicks == 1)
            {
            }
            else if (e.Button == MouseButtons.Right && e.Clicks == 1)
            {
                ContextMenu m1 = new ContextMenu();
                m1.MenuItems.Add("删除图片");
                m1.MenuItems.Add("添加图片");
                m1.Show(btn, new Point(e.X, e.Y));
                m1.MenuItems[0].Click += delegate
                {
                    MessageBox.Show("----");
                };
                m1.MenuItems[1].Click += delegate
                {
                    MessageBox.Show("++++");
                };

            }
        }
        void btn_DoubleClick(object sender, EventArgs e, string office)
        {
            MessageBox.Show(office);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Tencent t1 = new Tencent();
            this.Hide();
            t1.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        { 
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "Word文件(*.doc)|*.doc";
            sfd.RestoreDirectory = true;
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //try
                {
                    string saveFileName = sfd.FileName;
                    string localFilePath;
                    //FileStream fs = new FileStream(saveFileName, FileMode.OpenOrCreate, FileAccess.Write);
                    //获得文件路径 
                    localFilePath = sfd.FileName.ToString(); 
                    //获取文件名，不带路径 
                    string fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1); 
                    
                    //获取文件路径，不带文件名 
                    string FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\")); 
                    MessageBox.Show("获取文件名，不带路径:"+fileNameExt+"\n"+ "获取文件路径，不带文件名:"+FilePath);

                }
                //catch (Exception ex)
                //{

                //    MessageBox.Show("下载文件失败！");
                //}
            }
        }


    }
}
